package com.carskeeper.controller.body;

import com.alibaba.dubbo.config.annotation.Reference;
import com.carskeeper.body.service.BodyProviderService;
import com.carskeeper.common.dtos.PageResponseResult;
import com.carskeeper.common.dtos.ResponseResult;
import com.carskeeper.model.body.dtos.BodyProviderDto;
import com.carskeeper.model.body.dtos.QueryProviderDto;
import com.carskeeper.model.body.dtos.UpdateProvideStatusDto;
import com.carskeeper.model.body.pojos.BodyProvider;
import com.carskeeper.model.body.vo.BodyProviderListUserVo;
import com.carskeeper.model.body.vo.BodyProviderListVo;
import com.carskeeper.model.body.vo.BodyServiceVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "提供商主体")
@RestController
@RequestMapping("/body/provider")
public class BodyProviderController {

    @Reference
    private BodyProviderService bodyProviderService;

    /**
     * 分页查询服务商
     * @param dto
     * @return
     */
    @ApiOperation("分页查询服务商")
    @PostMapping("providerList")
    public PageResponseResult<List<BodyProviderListVo>> providerList(@RequestBody QueryProviderDto dto){
        return bodyProviderService.providerList(dto);
    }

    /**
     * 锁定服务商
     * @param dto
     * @return
     */
    @ApiOperation("锁定服务商")
    @PostMapping("lockProvider")
    public ResponseResult updateProviderStatus(@RequestBody UpdateProvideStatusDto dto){
        return bodyProviderService.updateProviderStatus(dto);
    }

    /**
     * 修改回显服务商
     * @param id
     * @return
     */
    @ApiOperation("修改回显服务商")
    @GetMapping("findService")
    public ResponseResult<BodyServiceVo> findService(Long id){
        return bodyProviderService.findService(id);
    }

    /**
     * 保存服务商
     * @param
     * @return
     */
    @ApiOperation("保存服务商")
    @PostMapping("saveProvider")
    public ResponseResult saveProvider(@RequestBody BodyProviderDto dto){
        return bodyProviderService.saveProvider(dto);
    }

    /**
     * 主体用户主体列表
     * @param dto
     * @return
     */
    @ApiOperation("分页查询服务商")
    @PostMapping("providerBodyList")
    public PageResponseResult<List<BodyProviderListUserVo>> providerBodyList(@RequestBody QueryProviderDto dto){
        return bodyProviderService.providerBodyList(dto);
    }
}
